package org.teach.study.boot.service.impl;

import java.util.List;

import org.quincy.rock.core.vo.PageSet;
import org.quincy.rock.core.vo.Sort;
import org.springframework.stereotype.Service;
import org.teach.study.boot.BaseService;
import org.teach.study.boot.dao.DeptDao;
import org.teach.study.boot.entity.Dept;
import org.teach.study.boot.provider.MybatisSQLProvider;
import org.teach.study.boot.service.DeptService;

/**
 * <b>DeptServiceImpl。</b>
 * <p><b>详细说明：</b></p>
 * <!-- 在此添加详细说明 -->
 * 无。
 * 
 * @version 1.0
 * @author mex2000
 * @since 1.0
 */
@Service
public class DeptServiceImpl extends BaseService<Dept, DeptDao> implements DeptService {

	@Override
	public PageSet<Dept> queryPageByCondition(String code, String name, Sort sort, int page, int pageSize) {
		long count = operate().countByCondition(code, name);
		PageSet<Dept> ps = new PageSet<>(page, pageSize);
		ps.setTotalCount(count);
		if (Sort.isSorted(sort)) {
			sort.setInterceptor(MybatisSQLProvider.CONV_FIELD_NAME);
		}
		List<Dept> list = operate().findPageByCondition(code, name, sort, ps.getBeginIndex(), pageSize);
		ps.setContent(list);
		return ps;
	}

}
